<template>
  <div class="page">
    <div>
      <img src="../../images/404@2x.png" alt="" />
      <p>
        页面被偷走啦！</br>{{ time }}秒后将自动返回首页或<span @click="$router.push({ path: '/dashboard' })">点击此处</span>
      </p>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Page404',
  data() {
    return {
      time: 5,
    }
  },
  activated() {
    this.countdown()
  },
  deactivated() {
    clearInterval(this.timer)
  },
  methods: {
    countdown() {
      clearInterval(this.timer)
      this.timer = setInterval(() => {
        this.time--
        if (this.time < 0) {
          this.$router.push({ path: '/dashboard' })
          clearInterval(time)
        }
      }, 1000)
    },
  },
}
</script>

<style lang="scss" scoped>
.page {
  > div {
    width: 35%;
    height: 35%;
    position: absolute;
    top: 16%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    img {
      width: 80%;
      margin-bottom: 23px;
    }
    p {
      color: #a8a8a8;
      font-weight: 600;
      line-height: 25px;
    }
    span {
      cursor: pointer;
      color: #1890FF;
    }
  }
}
</style>
